VERSION 5.00
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmChangeTranNo 
   BorderStyle     =   0  'None
   Caption         =   "Change Transaction Number"
   ClientHeight    =   1485
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   2790
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   1485
   ScaleWidth      =   2790
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   315
      Left            =   1440
      TabIndex        =   2
      Top             =   1080
      Width           =   1215
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "&OK"
      Height          =   315
      Left            =   120
      TabIndex        =   1
      Top             =   1080
      Width           =   1155
   End
   Begin VB.Frame Frame1 
      Caption         =   "Change Transaction No."
      Height          =   855
      Left            =   120
      TabIndex        =   3
      Top             =   120
      Width           =   2535
      Begin ITGControls.ITGTextBox txtTranNo 
         Height          =   285
         Left            =   180
         TabIndex        =   0
         Top             =   360
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14745599
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Label           =   "Sales Order No."
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   2115
      End
   End
End
Attribute VB_Name = "frmChangeTranNo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

Enum eCTNoType
    Change_SONo
    Change_ARNo
    Change_APNo
    Change_DRNo
    Change_PRNo
    Change_PONo
    Change_SINo
    Change_VoucherNo
End Enum

Public mType As eCTNoType
Public mTranNo As String

Private Sub cmdCancel_Click()
    Select Case mType
        Case Change_SONo
            frmBasicARSalesOrder.TBUndoAll
        Case Change_ARNo
            frmBasicARAdjustments.TBUndoAll
        Case Change_APNo
            frmBasicAPAdjustments.TBUndoAll
        Case Change_DRNo
            frmBasicMIDeliveryReceipt.TBUndoAll
        Case Change_PRNo
            'frmAPPurchaseRequest.TBUndoAll
        Case Change_PONo
            frmBasicAPPurchaseOrder.TBUndoAll
        Case Change_SINo
            frmBasicARSalesInvoice.TBUndoAll
        Case Change_VoucherNo
            frmBasicAPVoucherMain.TBUndoAll
    End Select
    
    Unload Me
End Sub

Private Sub cmdOK_Click()
    If Not CheckExistingOK Then Exit Sub
    
    Select Case mType
        Case Change_SONo
            frmBasicARSalesOrder.ChangeTranNo (mTranNo)
        Case Change_ARNo
            frmBasicARAdjustments.ChangeTranNo (mTranNo)
        Case Change_APNo
            frmBasicAPAdjustments.ChangeTranNo (mTranNo)
        Case Change_DRNo
            frmBasicMIDeliveryReceipt.ChangeTranNo (mTranNo)
        Case Change_PRNo
            'frmAPPurchaseRequest.ChangeTranNo (mTranNo)
        Case Change_PONo
            frmBasicAPPurchaseOrder.ChangeTranNo (mTranNo)
        Case Change_SINo
            frmBasicARSalesInvoice.ChangeTranNo (mTranNo)
        Case Change_VoucherNo
            frmBasicAPVoucherMain.ChangeTranNo (mTranNo)
    End Select
    
    Unload Me
End Sub

Function CheckExistingOK() As Boolean
Dim sFieldNo As String
Dim sTable As String
Dim sCriteria As String
Dim lCompany As Boolean

    txtTranNo = Trim(txtTranNo)

    Select Case mType
        Case Change_SONo
            sFieldNo = "cSONo"
            sTable = "SO"
            sCriteria = "cSONo = '" & Trim(txtTranNo) & "'"
            lCompany = False
        Case Change_ARNo
            sFieldNo = "cTranNo"
            sTable = "AR"
            sCriteria = "cTranNo = '" & Trim(txtTranNo) & "'"
            lCompany = False
        Case Change_APNo
            sFieldNo = "cTranNo"
            sTable = "AP"
            sCriteria = "cTranNo = '" & Trim(txtTranNo) & "'"
            lCompany = False
        Case Change_DRNo
            sFieldNo = "cDRNo"
            sTable = "DR"
            sCriteria = "cDRNo = '" & Trim(txtTranNo) & "' "
            lCompany = False
        Case Change_PRNo
            sFieldNo = "cPRNo"
            sTable = "REQUISITION"
            sCriteria = "cPRNo = '" & Trim(txtTranNo) & "'"
            lCompany = False
        Case Change_PONo
            sFieldNo = "cPONo"
            sTable = "PO"
            sCriteria = "cPONo = '" & Trim(txtTranNo) & "'"
            lCompany = False
        Case Change_SINo
            sFieldNo = "cInvNo"
            sTable = "SALES"
            sCriteria = "cInvNo = '" & Trim(txtTranNo) & "' "
            lCompany = False
        Case Change_VoucherNo
            sFieldNo = "cTranNo"
            sTable = "VOUCHER"
            sCriteria = "cTranNo = '" & Trim(txtTranNo) & "'"
            lCompany = False
    End Select
    
    CheckExistingOK = False
    
    If GetValueFrTable(sFieldNo, sTable, sCriteria, lCompany) <> "" Then
        MsgBox "Transaction No. already exists.", vbInformation, "ComUnion"
        txtTranNo.SetFocus
        Exit Function
    End If
    
    CheckExistingOK = True
    
End Function

Private Sub Form_Unload(Cancel As Integer)
    Set frmChangeTranNo = Nothing
End Sub

Private Sub txtTranNo_Change()
    mTranNo = Trim(txtTranNo)
End Sub

